package com.itheima.Demo;

import com.itheima.Utils.MybatisUtils;
import com.itheima.dao.OrderMapper;
import com.itheima.dao.UserMapper;
import com.itheima.pojo.Order;
import com.itheima.pojo.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

public class Demo01 {
    @Test
    public void Test01(){
        //注解方式实现，查询订单编号20140921003订单信息，并查询出下单人信息。
        SqlSessionFactory sqlSessionFactory = MybatisUtils.getSqlSessionFactory();
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        //==========================================
        UserMapper mapper1 = sqlSession.getMapper(UserMapper.class);
        User ubyId = mapper1.findUbyId(1);
        System.out.println(ubyId);
        OrderMapper mapper = sqlSession.getMapper(OrderMapper.class);
        Order order = mapper.find("20140921003");
        System.out.println(order);
        sqlSession.close();
    }

     @Test
     public void Test02(){
       //根据用户id查询对应的用户信息  订单信息 商品
         SqlSessionFactory sqlSessionFactory = MybatisUtils.getSqlSessionFactory();
         SqlSession sqlSession = sqlSessionFactory.openSession(true);
         UserMapper mapper = sqlSession.getMapper(UserMapper.class);
         User mapper0002 = mapper.find0002(2);
         System.out.println(mapper0002);
         sqlSession.close();
     }
}
